package com.bo.threadMethod;

/**
 * @Author: gpb
 * @Date: 2024/7/14 10:47
 * @Description:
 */
public class ThreadJoin {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName() + ":" + i);
                try {
                    Thread.sleep(1000);
                } catch (Exception e) {
                }
            }
        });
        t1.start();
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + ":" + i);
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
            }
            if (i == 5) {
                try {
                    t1.join(2000);
                } catch (Exception e) {
                }
            }
        }
    }
}
